package cool.webstudy.admin.controller.notice;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import cool.webstudy.admin.model.dto.notice.CreateNoticeDTO;
import cool.webstudy.admin.model.dto.notice.PaginationQueryNoticeInfoListDTO;
import cool.webstudy.admin.model.dto.notice.UpdateNoticeDTO;
import cool.webstudy.admin.model.vo.notice.PaginationQueryNoticeInfoListVO;
import cool.webstudy.admin.model.vo.notice.QueryNoticeDetailInfoVO;
import cool.webstudy.admin.service.NoticeService;
import cool.webstudy.admin.utils.aspect.request.RequestParameterCheck;
import cool.webstudy.admin.utils.common.Result;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Tag(name= "公告内容")
@RestController
@RequestMapping("/notice")
@RequestParameterCheck
public class NoticeController {
    @Autowired NoticeService noticeService;

    @GetMapping("/query/detail-info")
    @Operation(summary = "获取公告内容详细信息接口")
    public Result queryDetailInfo(@RequestParam String unCode) {
        QueryNoticeDetailInfoVO vo = noticeService.queryNoticeDetailInfo(unCode);

        return Result.success(vo);
    }

    @PostMapping("/create")
    @Operation(summary = "创建公告内容接口")
    public Result create(@RequestBody CreateNoticeDTO dto){
        noticeService.createNotice(dto);
        return Result.success();
    }

    @PostMapping("/update")
    @Operation(summary = "更新公告内容接口")
    public Result update(@RequestBody UpdateNoticeDTO dto){
        noticeService.updateNotice(dto);
        return Result.success();
    }

    @PostMapping("/batch/delete")
    @Operation(summary = "批量删除公告内容接口")
    public Result batchDelete(@RequestBody List<String> unCodeList){
        noticeService.batchDeleteNotice(unCodeList);
        return Result.success();
    }

    @PostMapping("/page-query/list")
    @Operation(summary = "分页获取公告内容信息列表接口")
    public Result<Page<PaginationQueryNoticeInfoListVO>> paginationQueryNoticeInfoList(@RequestBody PaginationQueryNoticeInfoListDTO dto){
        Page<PaginationQueryNoticeInfoListVO> vo = noticeService.paginationQueryNoticeInfoList(dto);
        return Result.success(vo);
    }
}
